<?php
namespace Wx\Controller;
use Think\Controller;
class CommonController extends Controller {
	// 初始化方法  
    public function _initialize(){
		if($_GET['adid']){
			//dump($_GET['adid']);
			//检查并绑定openid
			$user=D('user');
			$getone=$user->where("`www_openid` LIKE '".$_GET['adid']."'")->find();
			if($getone){
				//echo "ok";
				//设置登录状态
				session('uid',$getone['id']);
				}else{
					//echo "no";
					//绑定新用户
					$data['nickname']=$_GET['nickname'];
					$data['www_openid']=$_GET['adid']; 
					if($_GET['nickname']!='' and $_GET['adid']!='')$alt=$user->add($data);
					if($alt>0)session('uid',$alt);
			}
		}
	}//end fun
}